package Top_Interview_Questions.Two_Pointers;

/**
 * @Author: 吕庆龙
 * @Date: 2020/3/11 15:17
 * <p>
 * 功能描述:
 */
public class _0011 {

    /**
     * https://leetcode-cn.com/problems/container-with-most-water/solution/container-with-most-water-shuang-zhi-zhen-fa-yi-do/
     * 消状态讲的很好
     */
    public int maxArea(int[] height) {
        int i = 0, j = height.length - 1, res = 0;
        while(i < j){
            res = height[i] < height[j] ?
                    Math.max(res, (j - i) * height[i++]):
                    Math.max(res, (j - i) * height[j--]);
        }
        return res;
    }


}
